<?php

/**
 * Description of Environment
 *
 * @author Alexey
 */
class Environment
{
    const ENV_FILE = "/.env";
    const ENV_DIR = "/env";
    private $_envName;
    private $_envConfigFile;

    public function __construct()
    {
        $this->_envName = "";
        $this->_envConfigFile = "";
        if ( file_exists( Environment::getPathToEnvFile() ) )
        {
            $this->_envName = trim( file_get_contents( Environment::getPathToEnvFile() ) );
            $this->_envConfigFile = Environment::getEnvDir() . "/" . $this->_envName . ".php";
            if (!file_exists($this->_envConfigFile))
            {
                throw new Exception("Окружение " . $this->_envName . " не обнаружено.");
            }
        }
    }

    public static function getPathToEnvFile()
    {
        return AppConfig::getConfigDir() . Environment::ENV_FILE;
    }

    public function getEnvConfigFile()
    {
        return $this->_envConfigFile;
    }

    public static function getEnvDir()
    {
        return AppConfig::getConfigDir() . Environment::ENV_DIR;
    }

    public function getEnvName()
    {
        return $this->_envName;
    }



}

?>